<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<title>Document</title>
	<script>
		const arr = [{
			activity_id: 0,
			activity_name: "",
			goods_id: 44,
			goods_name: "测试商品1",
			goods_type: 1,
			type: true,
			specs: [{
				activity_id: 0,
				goods_id: 44,
				quantity: 3,
				record_id: 15,
				sale_price: "9.00",
				sku: "9787557023454",
				specs_id: 97,
				type: true
			}, {
				activity_id: 0,
				goods_id: 44,
				goods_type: 1,
				quantity: 1,
				record_id: 14,
				sale_price: "40.00",
				sku: "SGX-FSS-HZSX-Z",
				specs_id: 98,
				type: true,
			}]
		}, {
			activity_id: 0,
			activity_name: "",
			goods_id: 44,
			goods_name: "测试商品1",
			goods_type: 1,
			type: true,
			specs: [{
				activity_id: 0,
				goods_id: 44,
				quantity: 3,
				record_id: 15,
				sale_price: "9.00",
				sku: "9787557023454",
				specs_id: 97,
				type: true
			}, {
				activity_id: 0,
				goods_id: 44,
				goods_type: 1,
				quantity: 1,
				record_id: 14,
				sale_price: "40.00",
				sku: "SGX-FSS-HZSX-Z",
				specs_id: 98,
				type: true,
			}]
		}]
		// list: [{
		// 	id: goods_id,
		// 	specs: [{
		// 		count: specs.quantity,
		// 		sku: specs.sku
		// 	}]
		// }]
		const obj = arr.reduce((pre, item) => {
			item.specs.forEach((val => {
				if (!val.type) return
				if (Object.prototype.hasOwnProperty.call(pre.uniq, item.goods_id + '')) {
					pre.uniq[item.goods_id].push({
						count: val.quantity,
						sku: val.sku
					})
				} else {
					const arr = []
					pre.uniq[item.goods_id] = arr
					arr.push({
						count: val.quantity,
						sku: val.sku
					})
					pre.params.push({
						id: item.goods_id,
						specs: arr
					})
				}
			}))
			return pre
		}, {
			uniq: {},
			params: []
		})
		console.log(obj)
	</script>
</head>

<body>
</body>

</html>